package br.com.statizo.financeiro.swt.filter;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.snoghertframework.swt.annotations.FilterComponent;
import org.snoghertframework.swt.filter.ApplicationFilter;
import org.snoghertframework.swt.util.impl.LayoutUtil;
import org.springframework.beans.factory.annotation.Autowired;

@FilterComponent(description="Criando tabela de lançamentos")
public class CreateLancamentoCompositeFilter implements ApplicationFilter{

	@Autowired
	private TabFolder tabFolder;
	
	@Autowired
	private LayoutUtil layoutUtil;
	
	
	@Override
	public void doFilter() {

		 TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
		 tabItem.setText("Lançamento");

		 Composite lancComp = new Composite(tabFolder, SWT.NONE);
		 layoutUtil.setFormLayout(lancComp);
		 layoutUtil.setFormData(lancComp, 10, 30, 90, 90);

		 tabItem.setControl(lancComp);
		 
		 
		 Composite actionComposite = new Composite(lancComp,SWT.NONE);
		 layoutUtil.setFormLayout(actionComposite);
		 layoutUtil.setFormData(actionComposite, 10, 30, 90, 15);
		 
		 Button button = new Button(actionComposite,SWT.NONE);
		 layoutUtil.setFormData(button, 2, 2, 20, 50);
		 button.setText("add (+)");
		 //button.addMouseListener(lancamentoDialogListener);

		 
		 Label separator = new Label(actionComposite,SWT.SEPARATOR | SWT.HORIZONTAL);
		 layoutUtil.setFormData(separator, 99, 0, 100, 100);
		 
		 Table table = new Table(lancComp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
		 table.setHeaderVisible(true);
		 table.setLinesVisible(true);
		 
		 layoutUtil.setFormData(table, 18, 30, 90, 90);
		 
		 createColumn("Dt. Dívida",table);
		 createColumn("Dt. Vcto.",table);

		 TableItem item = new TableItem(table, SWT.NONE);
		 item.setText(new String[]{"A","B"});		
		
		
	}

	
	

	
	protected void createColumn(String header, Table table){
		
		 TableColumn tableColumn = new TableColumn(table, SWT.BORDER | SWT.NO_REDRAW_RESIZE);		 
		 tableColumn.setText(header);
		 tableColumn.setResizable(true);
		 tableColumn.pack();
		
	}
	
	
}
